﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace IteratorPattern.structural
{
    /// <summary>
    /// 具體聚合，實現相應迭代器的接口，返回具體迭代器的一個適當的實例
    /// </summary>
    public class ConcreteAggregate : Aggregate
    {
        private List<object> _items = new List<object>();
        public override Iterator CreateIterator()
        {
            return new ConcreteIterator(this);
        }

        public int Count
        {
            get { return _items.Count; }
        }

        public object this[int index]
        {
            get { return _items[index]; }
            set { _items.Insert(index, value); }
        }
    }
}
